package jdk8.lambda;

import com.kclm.se.inter.Movable;

public class UseLambdaDemo {

	public static void main(String[] args) {
		Movable plane = new Movable() {
			
			@Override
			public void move(int direction, int speed) {
				System.out.printf("飞机以[%d]的时速向%s方向飞去\n",
						speed, convertDirection(direction));
			}
		};
		//
		plane.move(Movable.NORTH, 350);
		System.out.println("------使用Lambda表达式来改写 -----------------");
		Movable car = (direction, speed) -> System.out.printf("汽车以[%d]的时速向%s方向驶去\n",
										speed, Movable.staticConvert(direction));
		car.move(Movable.EAST, 120);
		
		//
		Thread t = new Thread(new Runnable() {
			
			@Override
			public void run() {
				System.out.println(Thread.currentThread().getName()+" print ...");
			}
		});
		t.start();
		//
		System.out.println("---------- Lambda 表达式改写 ------------");
		new Thread(() -> System.out.println(Thread.currentThread().getName()+" print...")).start();
	}
}
